<template>
  <div class="singerDetails w">
    <div v-if="Object.keys(singerInfo).length !== 0">
      <div class="singerDetails_info">
        <el-row type="flex">
          <el-col :span="6">
            <GlobalImageDeep
              :imgWidth="250"
              :imgHeight="250"
              :url="singerInfo.artist.cover"
            />
          </el-col>
          <el-col :span="17" :offset="1">
            <h2 :title="singerInfo.artist.name">
              {{ singerInfo.artist.name }}
            </h2>
            <div class="singerDetails_info_briefDesc">
              描述:&nbsp;
              {{ singerInfo.artist.briefDesc }}
            </div>
            <div class="singerDetails_info_btn">
              <el-button size="small" round>
                <i class="iconfont icon-shoucang"></i>
                收藏
              </el-button>
              <el-button size="small" round>
                <i class="el-icon-user"></i>
                个人主页
              </el-button>
            </div>
            <div class="singerDetails_info_count">
              <div
                class="singerDetails_info_count_item"
                @click="clickInfoCount('单曲')"
              >
                单曲
                <span>{{ singerInfo.artist.musicSize }}</span>
              </div>
              <div
                class="singerDetails_info_count_item"
                @click="clickInfoCount('专辑')"
              >
                专辑 <span>{{ singerInfo.artist.albumSize }}</span>
              </div>
              <div
                class="singerDetails_info_count_item"
                @click="clickInfoCount('MV')"
              >
                MV <span>{{ singerInfo.artist.mvSize }}</span>
              </div>
            </div>
          </el-col>
        </el-row>
        <!-- tab 栏 -->
        <el-tabs v-model="activeName">
          <el-tab-pane label="单曲" name="单曲">
            <!-- <el-empty
              v-if="Object.keys(singerInfo).length === 0"
              description="正在加载单曲~"
            ></el-empty> -->
            <singerSongsListComponent :id="singerInfo.artist.id"
          /></el-tab-pane>
          <el-tab-pane label="专辑" name="专辑">
            <singerAlbumsListComponent
              v-if="activeName == '专辑'"
              :id="singerInfo.artist.id"
              :total="singerInfo.artist.albumSize"
            />
          </el-tab-pane>
          <el-tab-pane label="MV" name="MV">
            <singerMvListComponent
              v-if="activeName == 'MV'"
              :id="singerInfo.artist.id"
              :total="singerInfo.artist.mvSize"
            />
          </el-tab-pane>
        </el-tabs>
      </div>
      <simiSingerComponent :id="singerInfo.artist.id" />
    </div>
    <el-empty v-else description="正在加载~~~~~~~"></el-empty>
  </div>
</template>

<script>
// 引入 接口 api
import { getSingerDetail } from "../../../../api/singerDetailsApi";
// 引入 自己的 组件
import singerSongsListComponent from "./components/singerSongsList";
import singerAlbumsListComponent from "./components/singerAlbumsList.vue";
import singerMvListComponent from "./components/singerMvList.vue";
import simiSingerComponent from "./components/simiSinger.vue";
export default {
  name: "singerDetails",
  components: {
    singerSongsListComponent,
    singerAlbumsListComponent,
    singerMvListComponent,
    simiSingerComponent,
  },
  data() {
    return {
      singerInfo: {}, // 歌手的详情
      activeName: "单曲",
      id: 0,
    };
  },
  created() {
    this.id = this.$route.params.id;
    this.getSingerDetailMethod();
  },
  methods: {
    // 获取 歌手的详情
    async getSingerDetailMethod() {
      try {
        let result = await getSingerDetail(this.id);
        if (result.code === 200) {
          this.singerInfo = result.data;
        }
      } catch (error) {}
    },
    // 点击 单曲、专辑、MV 的时候
    clickInfoCount(flag) {
      this.activeName = flag;
    },
  },
  watch: {
    "$route.params.id"(newValue, oldValue) {
      // console.log(newValue, oldValue);
      this.id = newValue;
      this.getSingerDetailMethod();
      // this.$forceUpdate();
    },
  },
  computed: {},
};
</script>

<style lang="less" scoped>
.singerDetails {
  padding: 30px 0;
  color: #000000;
  font-size: 14px;
  .singerDetails_info {
    /deep/ .el-image img {
      border-radius: 50%;
    }
    h2 {
      font-weight: normal;
      margin-bottom: 10px;
      &:hover {
        color: @globalColor;
        cursor: pointer;
      }
    }
    .singerDetails_info_btn {
      margin: 10px 0 20px;
      /deep/ .el-button {
        font-size: 14px;
      }
    }
    .singerDetails_info_count {
      display: flex;
      font-size: 18px;
      color: #333333;
      .singerDetails_info_count_item {
        margin-right: 10px;
        border-right: 1px solid #c9c9c9;
        padding-right: 20px;
        cursor: pointer;
        &:hover {
          color: @globalColor;
        }
      }
      span {
        font-size: 26px;
        margin-left: 10px;
      }
    }
  }
  // 样式覆盖
  /deep/ .el-tabs {
    padding-top: 20px;
  }

  /deep/ .el-tabs__item.is-active {
    color: @globalColor;
  }
  /deep/ .el-tabs .el-tabs__active-bar {
    background-color: @globalColor;
  }
  /deep/ .el-tabs .el-tabs__item {
    &:hover {
      color: @globalColor;
    }
  }
}
</style>
